package com.medium.house.enums;

/**
 * @author wang.yu
 */
public enum HouseTypeEnum {


    SECONDHAND(1, "二手房"),
    RANTAL(2, "出租房"),
    ;

    private Integer code;
    private String desc;

    HouseTypeEnum(Integer code, String desc){
        this.code = code;
        this.desc = desc;
    }

    public Integer getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }


    public static HouseTypeEnum toEnum(Integer code) {
        for (HouseTypeEnum item : HouseTypeEnum.values()) {
            if (item.code.equals(code)) {
                return item;
            }
        }
        StringBuilder str = new StringBuilder();
        str.append("the argument of ").append(code).append(" have no correspondence enum!");
        throw new IllegalArgumentException(str.toString());
    }


}
